<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('报警记录')" />
	<title>报警记录</title>
</head>
<body class="gray-bg">
    
     <div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="formId">
					<div class="select-list">
						<ul>
							<li>
								报警编号：<input type="text" name="id"/>
							</li>
							<li>
								标签ID：<input type="text" name="tagId"/>
							</li>

<!--							<li>-->
<!--								报警产生时间：<input type="text" name="alarmTS"/>-->
<!--							</li>-->

							<li>
								报警类型：<input type="text" name="alarmType"/>
							</li>

							<li>
								处理状态：<select name="status" th:with="type=${@dict.getType('tag_alarm_data')}">
								<option value="">所有</option>
								<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
							</select>
							</li>

							<li class="select-time">
								<label>创建时间： </label>
								<input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginTime]"/>
								<span>-</span>
								<input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endTime]"/>
							</li>

							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			
	        <div class="btn-group-sm" id="toolbar" role="group">
<!--				<a class="btn btn-primary btn-edit disabled" onclick="$.operate.editDeal()" shiro:hasPermission="system:tagAlarmData:edit">-->
<!--					<i class="fa fa-edit"></i> 处理-->
<!--				</a>-->
				<a class="btn btn-info" onclick="openRule()" shiro:hasPermission="system:tagAlarmData:rule">
					<i class="fa fa-magic"></i> 规则
			   </a>
				<a class="btn btn-primary" onclick="openIdea()" shiro:hasPermission="system:tagAlarmData:edit">
					<i class="fa fa-cog"></i> 处理意见设置
				</a>

<!--				<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:tagAlarmData:export">-->
<!--						<i class="fa fa-download"></i> 导出-->
<!--				 </a>-->
			</div>
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>
    <div th:include="include :: footer"></div>
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:tagAlarmData:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:tagAlarmData:remove')}]];
		var id = [[${id}]];
        var prefix = ctx + "system/tagAlarmData";
		var types = [[${@dict.getType('tag_alarm_data')}]];
		var alarmQuickTextList = [[${alarmQuickTextList}]];
        $(function() {
			$('input:not([autocomplete]),textarea:not([autocomplete]),select:not([autocomplete])').attr('autocomplete', 'off');
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
				exportUrl: prefix + "/export",
                modalName: "报警记录",
				queryParams:queryParams,
		        showExport: false,
				uniqueId:"id",
                columns: [{
		            checkbox: true
		        },
				{
					title: "序号",
					formatter: function (value, row, index) {
						return $.table.serialNumber(index);
					}
				},
				{
					field : 'id', 
					title : '报警编号',
					visible: true,
					formatter: function(value, row, index) {
						var html ="<span style='white-space:nowrap'>"+value+"</span>"
						return html;
					}
				},
				{
					field : 'tagId', 
					title : '标签ID',
					sortable: true,
					formatter: function(value, row, index) {
						var html ="<span style='white-space:nowrap'>"+value+"</span>"
						return html;
					}
				},
				{
					field : 'alarmTS', 
					title : '报警产生时间',
					sortable: false,
					formatter: function(value, row, index) {
						value = $.common.nullToStr(value);
						var html ="<span style='white-space:nowrap'>"+value+"</span>"
						return html;
					}
				},
				{
					field : 'alarmType', 
					title : '报警类型',
					sortable: false,
					formatter: function(value, row, index) {
						value = $.common.nullToStr(value);
						var html ="<span style='white-space:nowrap'>"+value+"</span>"
						return html;
					}
					// cellStyle:function(value,row,index){
					// 	return {css: {"color":"red"}}
					// }
				},
					{
						field : 'x,y,z',
						title : '位置坐标',
						sortable: false,
						visible: true,
						formatter:function (value,row,index) {
							var html ="<span style='white-space:nowrap'><span>"+row.x+",</span><span>"+row.y+",</span><span>"+row.z+"</span></span>"
							return html;
						}
					},
				{
					field : 'status', 
					title : '处理状态',
					sortable: true,
					formatter: function(value, row, index) {
						return $.table.selectDictLabel(types, value);
					}
				},
				{
					field : 'context', 
					title : '处理意见',
					sortable: false,
					formatter: function(value, row, index) {
						value = $.common.nullToStr(value);
						var html ="<span style='white-space:nowrap'>"+value+"</span>"
						return html;
					}
				},
				// {
				// 	field : 'createBy',
				// 	title : '创建者',
				// 	sortable: false,
				// 	formatter: function(value, row, index) {
				// 		value = $.common.nullToStr(value);
				// 		var html ="<span style='white-space:nowrap'>"+value+"</span>"
				// 		return html;
				// 	}
				// },
				{
					field : 'createTime', 
					title : '创建时间',
					sortable: true,
					formatter: function(value, row, index) {
						value = $.common.nullToStr(value);
						var html ="<span style='white-space:nowrap'>"+value+"</span>"
						return html;
					}
				},
				{
					field : 'updateBy', 
					title : '更新者',
					sortable: false,
					formatter: function(value, row, index) {
						value = $.common.nullToStr(value);
						var html ="<span style='white-space:nowrap'>"+value+"</span>"
						return html;
					}
				},
				{
					field : 'updateTime', 
					title : '更新时间',
					sortable: true,
					formatter: function(value, row, index) {
						value = $.common.nullToStr(value);
						var html ="<span style='white-space:nowrap'>"+value+"</span>"
						return html;
					}
				},
				{
					field : 'remark', 
					title : '备注',
					sortable: false,
					formatter: function(value, row, index) {
						value = $.common.nullToStr(value);
						var tooltip = $.table.tooltip(value);
						var html ="<span style='white-space:nowrap'>"+tooltip+"</span>"
						return html;
					}
				},
		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	var actions = [];
						actions.push('<span style=\'white-space:nowrap\'>');
						actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="editDeal(\'' + row.id + '\')"><i class="fa fa-edit"></i>处理</a> ');
						actions.push('<a class="btn btn-primary btn-xs ' + editFlag + '" href="#" onclick="locationAlarm(\'' + row.id + '\')"><i class="fa fa-play-circle-o"></i>定位</a> ');
						actions.push('</span>');
						return actions.join('');
		            }
		        }]
            };
            $.table.init(options);
        });
        function openRule() {
			$.modal.open("报警规则配置", "/system/tagAlarmData/rule","400","320");
		}
		function openIdea() {
			$.modal.open("处理意见设置", "/system/tagAlarmData/quickText","800","400");
		}
		function editDeal(id) {
        	var count = alarmQuickTextList.length;
        	var height = 390+(count*50);
			$.modal.open("处理" + $.table._option.modalName, $.operate.editUrl(id),800,height);
		}
		function locationAlarm(id) {
			$.modal.openTab("定位" + $.table._option.modalName,"/mapLocation/"+id);
		}
		function queryParams(params) {
			var search = $.table.queryParams(params);
			search.id = id;
			return search;
		}
    </script>
</body>
</html>